const DB = wx.cloud.database().collection('note_list');
const util = require("../../utils/util.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    title:"新建事件",
    isTransform:false,
    isBack:true,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  formSubmit: function (e) {
    let that = this;
    let date ={
      date:util.formatDate(new Date())[0],
      time:util.formatDate(new Date())[1]
    } 
    let all = util.extend(date, e.detail.value)
    console.log(all);
    if (e.detail.value.thing == "") {
      wx.showToast({
        title: '请输入标题',
        icon: 'none'
      })
    } else if (e.detail.value.context == "") {
      wx.showToast({
        title: '请输入详细内容',
        icon: 'none'
      })
    } else {
      DB.add({
        data: all,
        success: res => {
          console.log("添加成功", res);
          wx.showToast({
            title: '添加成功',
          })
          wx.navigateBack({
            delta: 1,
          })
        },
        fail: res => {
          console.log("添加失败", res);
        }
      })
    }
  },
})